package io.renren.modules.back.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.utils.R;
import io.renren.modules.back.entity.AttributeEntity;
import io.renren.modules.back.entity.CategoryEntity;
import io.renren.modules.back.service.AttributeService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 商品属性接口
 *
 * @author zzh
 * @email 862583291@qq.com
 * @date 2019年4月5日 上午10:40:10
 */
@RestController
@RequestMapping("/back/attribute")
public class AttributeController {
    @Autowired
    private AttributeService attributeService;

    /**
     * 查看列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("attribute:list")
    public R list(@RequestParam Map<String, Object> params) {
        String attributeCategoryId = (String) params.get("attributeCategoryId");
        List<AttributeEntity> attributes = attributeService.list(
                new QueryWrapper<AttributeEntity>().eq("attribute_category_id",attributeCategoryId).orderByAsc("id")
        );
        return R.ok().put("data", attributes);
    }
}
